public class LC01a {
    public static class ListNode {
        int val;
        LC01a.ListNode next;
        ListNode() {}
        ListNode(int val) { this.val = val; }
        ListNode(int val, LC01a.ListNode next) { this.val = val; this.next = next; }
    }
    class Solution {
        public ListNode removeElements(ListNode head, int val) {
            ListNode Head = new ListNode(0);
            Head.next = head;
            ListNode temp = Head;
            while (temp != null){
                if (temp.val == val){
                    temp.next = temp.next.next;
                }else{
                    temp = temp.next;
                }
            }
            return Head.next;
        }
    }
}
